<?php

namespace Client\Exception;

class ClientException extends \ErrorException
{
    
    public static $error_code = array(
        '2001' => '储值卡不存在',
        '2002' => '用户不存在',
        '3001' => '订单支付失败',
        '3002' => '创建订单失败',
        '3004' => '订单商品不存在',
        '3005' => '图片上传失败',
        '4001' => '注册用户失败',
        '5001' => '或许优惠券失败',
        '6001' => '提交退货申请失败',
        
    );
    
    
    
    /**
     * {@inheritDoc}
     * @see ErrorException::__construct()
     */
    public function __construct($code = null)
    {        
        parent::__construct(self::$error_code[$code],$code);
    }

    public function toJson()
    {
       return $response = array(
                'result' => false,
                'msg' =>$this->getMessage(),
                'error_code' =>$this->getCode()
            );
    }
}